package com.fpost.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.fpost.constants.ActionConstants;
import com.fpost.util.CommonUtils;

public class DispatchAction extends Action {
	
	private static Logger log = Logger.getLogger(DispatchAction.class);

	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		
		//set current path in session
		CommonUtils.setCurrentPathInSession(request, mapping);
		
		String forward = ActionConstants.SYSTEM_FAILURE;
		String dest = request.getParameter("dest");
		if (ActionConstants.LOGIN.equals(dest)){
			forward = ActionConstants.LOGIN;
		} else if (ActionConstants.REGISTER.equals(dest)){
			forward = ActionConstants.REGISTER;
		} 
		return mapping.findForward(forward);
	}
}
